package bishi.tengxun.three;

import java.util.Scanner;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/09/26 20:22
 */
public class two {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n>0){
            n--;
            int T = sc.nextInt();
            int[] nums = new int[T];
            int i=0;
            while (i<T){
                nums[i++] = sc.nextInt();
            }
            int max = 0;
            int[] res = new int[T];
            for (i=0;i<T;i++){
                if(res[i]>=nums[i])continue;
                int sum = 0;
                int index = i;
                while (index<T){
                    sum+=nums[index];
                    if(res[index]<sum){
                        res[index]=sum;
                    }else{
                        break;
                    }
                    index = index+nums[index];
                }
                max = Math.max(max,sum);
            }
            System.out.println(max);
        }
    }
}
